package cn.iocoder.yudao.module.form.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.form.dataobject.FormEquipment;
import cn.iocoder.yudao.module.form.service.IFormEquipmentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 设备采购Controller
 *
 * @author ruoyi
 * @date 2022-07-13
 */
@RestController
//@Slf4j
@Api(tags = "a设备采购")
@RequestMapping("/admin-api/equip/equipment")
public class FormEquipmentController
{
    @Autowired
    private IFormEquipmentService formEquipmentService;

    /**
     * 查询设备采购列表
     */
    @PreAuthorize("@ss.hasPermi('equip:equipment:list')")
    @GetMapping("/list")
    public CommonResult<List<FormEquipment>> list(FormEquipment formEquipment)
    {
//        startPage();
        List<FormEquipment> list = formEquipmentService.selectFormEquipmentList(formEquipment);
        return success(list);
    }

    /**
     * 导出设备采购列表
     */
//    @PreAuthorize("@ss.hasPermi('equip:equipment:export')")
//    @Log(title = "设备采购", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, FormEquipment formEquipment)
//    {
//        List<FormEquipment> list = formEquipmentService.selectFormEquipmentList(formEquipment);
//        ExcelUtil<FormEquipment> util = new ExcelUtil<FormEquipment>(FormEquipment.class);
//        util.exportExcel(response, list, "设备采购数据");
//    }

    /**
     * 获取设备采购详细信息
     */
    @PreAuthorize("@ss.hasPermi('equip:equipment:query')")
    @GetMapping(value = "/{equId}")
    public CommonResult<FormEquipment> getInfo(@PathVariable("equId") Long equId)
    {
        return success(formEquipmentService.selectFormEquipmentByEquId(equId));
    }

    /**
     * 新增设备采购
     */
    @PreAuthorize("@ss.hasPermi('equip:equipment:add')")
    @PostMapping
    public CommonResult<Integer> add(@RequestBody FormEquipment formEquipment)
    {
        return success(formEquipmentService.insertFormEquipment(formEquipment));
    }

    /**
     * 修改设备采购
     */
    @PreAuthorize("@ss.hasPermi('equip:equipment:edit')")
    @PutMapping
    public CommonResult<Integer> edit(@RequestBody FormEquipment formEquipment)
    {
        return success(formEquipmentService.updateFormEquipment(formEquipment));
    }

    /**
     * 删除设备采购
     */
    @PreAuthorize("@ss.hasPermi('equip:equipment:remove')")
	@DeleteMapping("/{equIds}")
    public CommonResult<Integer> remove(@PathVariable Long[] equIds)
    {
        return success(formEquipmentService.deleteFormEquipmentByEquIds(equIds));
    }
}
